import 'package:flutter_taotaoshipin/generated/json/base/json_convert_content.dart';
import 'package:flutter_taotaoshipin/model/goods_list_entity.dart';

GoodsListEntity $GoodsListEntityFromJson(Map<String, dynamic> json) {
  final GoodsListEntity goodsListEntity = GoodsListEntity();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    goodsListEntity.id = id;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    goodsListEntity.name = name;
  }
  final String? bottomText = jsonConvert.convert<String>(json['bottom_text']);
  if (bottomText != null) {
    goodsListEntity.bottomText = bottomText;
  }
  final int? goodsType = jsonConvert.convert<int>(json['goods_type']);
  if (goodsType != null) {
    goodsListEntity.goodsType = goodsType;
  }
  final String? spec = jsonConvert.convert<String>(json['spec']);
  if (spec != null) {
    goodsListEntity.spec = spec;
  }
  final double? amount = jsonConvert.convert<double>(json['amount']);
  if (amount != null) {
    goodsListEntity.amount = amount;
  }
  final double? subAmount = jsonConvert.convert<double>(json['sub_amount']);
  if (subAmount != null) {
    goodsListEntity.subAmount = subAmount;
  }
  final int? money = jsonConvert.convert<int>(json['money']);
  if (money != null) {
    goodsListEntity.money = money;
  }
  final int? giveMoney = jsonConvert.convert<int>(json['give_money']);
  if (giveMoney != null) {
    goodsListEntity.giveMoney = giveMoney;
  }
  final int? days = jsonConvert.convert<int>(json['days']);
  if (days != null) {
    goodsListEntity.days = days;
  }
  final int? light = jsonConvert.convert<int>(json['light']);
  if (light != null) {
    goodsListEntity.light = light;
  }
  final String? subscript = jsonConvert.convert<String>(json['subscript']);
  if (subscript != null) {
    goodsListEntity.subscript = subscript;
  }
  final GoodsListConfig? config = jsonConvert.convert<GoodsListConfig>(
      json['config']);
  if (config != null) {
    goodsListEntity.config = config;
  }
  final int? ctime = jsonConvert.convert<int>(json['ctime']);
  if (ctime != null) {
    goodsListEntity.ctime = ctime;
  }
  return goodsListEntity;
}

Map<String, dynamic> $GoodsListEntityToJson(GoodsListEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['name'] = entity.name;
  data['bottom_text'] = entity.bottomText;
  data['goods_type'] = entity.goodsType;
  data['spec'] = entity.spec;
  data['amount'] = entity.amount;
  data['sub_amount'] = entity.subAmount;
  data['money'] = entity.money;
  data['give_money'] = entity.giveMoney;
  data['days'] = entity.days;
  data['light'] = entity.light;
  data['subscript'] = entity.subscript;
  data['config'] = entity.config?.toJson();
  data['ctime'] = entity.ctime;
  return data;
}

extension GoodsListEntityExtension on GoodsListEntity {
  GoodsListEntity copyWith({
    int? id,
    String? name,
    String? bottomText,
    int? goodsType,
    String? spec,
    double? amount,
    double? subAmount,
    int? money,
    int? giveMoney,
    int? days,
    int? light,
    String? subscript,
    GoodsListConfig? config,
    int? ctime,
  }) {
    return GoodsListEntity()
      ..id = id ?? this.id
      ..name = name ?? this.name
      ..bottomText = bottomText ?? this.bottomText
      ..goodsType = goodsType ?? this.goodsType
      ..spec = spec ?? this.spec
      ..amount = amount ?? this.amount
      ..subAmount = subAmount ?? this.subAmount
      ..money = money ?? this.money
      ..giveMoney = giveMoney ?? this.giveMoney
      ..days = days ?? this.days
      ..light = light ?? this.light
      ..subscript = subscript ?? this.subscript
      ..config = config ?? this.config
      ..ctime = ctime ?? this.ctime;
  }
}

GoodsListConfig $GoodsListConfigFromJson(Map<String, dynamic> json) {
  final GoodsListConfig goodsListConfig = GoodsListConfig();
  final String? appleGoodsId = jsonConvert.convert<String>(
      json['apple_goods_id']);
  if (appleGoodsId != null) {
    goodsListConfig.appleGoodsId = appleGoodsId;
  }
  return goodsListConfig;
}

Map<String, dynamic> $GoodsListConfigToJson(GoodsListConfig entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['apple_goods_id'] = entity.appleGoodsId;
  return data;
}

extension GoodsListConfigExtension on GoodsListConfig {
  GoodsListConfig copyWith({
    String? appleGoodsId,
  }) {
    return GoodsListConfig()
      ..appleGoodsId = appleGoodsId ?? this.appleGoodsId;
  }
}